#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_payButton_clicked()
{
    QString amount = ui->amountLineEdit->text();
    // 调用微信支付接口，完成支付操作

    // 模拟支付结果
    bool success = true;
    showPaymentResult(success);
}

void MainWindow::showPaymentResult(bool success)
{
    if (success) {
        QMessageBox::information(this, "Payment Result", "Payment successful!");
    } else {
        QMessageBox::critical(this, "Payment Result", "Payment failed!");
    }
}
WechatPayManager *wechatPayManager = new WechatPayManager(this);

connect(wechatPayManager, &WechatPayManager::payRequestFinished, [=](bool success) {
    if (success)
    {
        // 支付成功
    }
    else
    {
        // 支付失败
    }
});

// 触发支付请求
wechatPayManager->pay("20220101001", 10.0); // 替换为实际的订单号和金额
